<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateAppStartLogTable extends Migration
{
    protected $connection = 'stat';

    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('app_start_log', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->tinyInteger('app_id')->default(1)->comment('应用ID');
            $table->tinyInteger('platform')->default(2)->comment('平台：1-IOS，2-安卓');
            $table->char('device_id', 40)->default('')->comment('设备ID');
            $table->char('client_ip', 20)->default('')->comment('IP');
            $table->char('channel', 10)->default('')->comment('渠道ID');
            $table->string('device')->default('')->comment('设备型号');
            $table->char('app_version', 10)->default('')->comment('APP版本');
            $table->char('sys_version', 6)->default(0)->comment('手机系统版本');
            $table->timestamps();
            $table->tinyInteger('flag')->default(1)->comment('记录状态');
            $table->index('device_id', 'device_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('app_start_log');
    }
}
